package com.yunchao.maintenance.presentation.screen

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter4.BaseQuickAdapter
import com.yunchao.maintenance.databinding.AdapterMainItemLayoutBinding
import com.yunchao.maintenance.domain.model.MaintenanceInfoModel
import com.yunchao.maintenance.R

internal class MainAdapter : BaseQuickAdapter<MaintenanceInfoModel,MainAdapter.VH>() {
    override fun onBindViewHolder(
        holder: VH,
        position: Int,
        item: MaintenanceInfoModel?
    ) {
        holder.binding.textView1.text = item?.lockNo
        holder.binding.textView2.text = context.getString(R.string.出厂日期,item?.manufactureDate)
        holder.binding.textView3.text = context.getString(R.string.销售地点,item?.salesLocation)
        holder.binding.textView4.text = context.getString(R.string.质保日期,item?.warrantyPeriod)
    }

    override fun onCreateViewHolder(
        context: Context,
        parent: ViewGroup,
        viewType: Int
    ): VH = VH(parent)

    inner class  VH(
        parent: ViewGroup,
        val binding: AdapterMainItemLayoutBinding = AdapterMainItemLayoutBinding.inflate(
            LayoutInflater.from(parent.context), parent, false
        )
    ) : RecyclerView.ViewHolder(binding.root)
}